/* 
  这是一个容器组件
*/

// 引入UI组件
import Calculator from "../../components/Calculator";
// 移入dispatch
import { incrementAction, decrementAction, asyncIncrementAction } from '../../redux/count_action'

// 引入content用于连接UI组件和redux
import { connect } from 'react-redux'

function mapStateToProps(state) {
  return { count: state }
}

function mapDispatchToProps(dispatch) {
  return {
    increment: number => dispatch(incrementAction(number)),
    decrement: number => dispatch(decrementAction(number)),
    asyncIncrement: (number, time) => dispatch(asyncIncrementAction(number, time))
  }
}

// 创建并暴露一个Calculator容器组件
export default connect(mapStateToProps, mapDispatchToProps)(Calculator)